Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

222
Views
UnhandledPromiseRejectionWarning: CastError: Cast to ObjectId failed for value "login" (type string) at path "_id" for model "User"

How to solve this problem? I am new into NodeJS. This is my Model User:

const userSchema = mongoose.Schema(
  {
    name: {
      type: String,
      required: true,
    },
    email: {
      type: String,
      required: true,
      unique: true,
    },
    password: {
      type: String,
      required: true,
    },
    isAdmin: {
      type: Boolean,
      required: true,
      default: false,
    },
  },
  {
    timestamps: true,
  }
);

This is my route file, i mean this /login route where i call get method on authuser function

router.post('/login', authUser);

And this is my authUser function:

const authUser = async (req, res) => {
  const { email, password } = req.body;

  res.send({ email, password });
};

Simple function without any logic but i just want to see respond, i use postman to auth user and i get that error in console...

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!